<?php
/**
 * Created by PhpStorm.
 * Author: sitenv@aliyun.com
 * CreateTime: 2023/2/14 12:59
 * Blog：www.myblogs.xyz
 */

namespace App\Controller;

use Hyperf\Di\Annotation\Inject;
use App\Models\ArticlesModels;
use App\Services\Api2Services;

class TestController extends AbstractController
{
    #[Inject]
    protected Api2Services $api2;

    public function index()
    {
        $this->api2->require = ['user'];
        $this->api2->selectable = ['test'];
        if (!$this->api2->verifyParam($this->request)) return $this->api2->verifyError();

        return $this->api2->jsonResult($this->api2->data);
    }

    public function articles()
    {
        $this->api2->require = ['user_id'];
        if (!$this->api2->verifyParam($this->request)) return $this->api2->verifyError();
        $articlesModels = new ArticlesModels();
        $articleList = $articlesModels->getList($this->api2->data);

        return $this->api2->jsonResult($articleList);
    }
}